package top.luckyluxcis.api;

import lombok.experimental.UtilityClass;
import top.luckyluxcis.RollApi;
import top.luckyluxcis.type.PhoneCode;
import top.luckyluxcis.type.PhoneLocation;
import top.luckyluxcis.util.MapUtil;

import java.util.List;
import java.util.Map;

/**
 * @author Zhuang
 * @since 2023/9/21
 */
@SuppressWarnings("unused")
@UtilityClass
public class PhoneUtil {
    private static final RollApi API = RollApi.getInstance();

    /**
     * 获取世界电话区号列表
     *
     * @return {@link List}<{@link PhoneCode}>
     */
    public static List<PhoneCode> list() {
        return API.get("/phone_code/list", MapUtil.empty(), List.class, PhoneCode.class);
    }

    /**
     * 手机号码归属地查询
     *
     * @param mobile 目标手机号码
     * @return {@link PhoneLocation}
     */
    public static PhoneLocation location(String mobile) {
        Map<String, Object> params = MapUtil.<String, Object>builder()
                .put("mobile", mobile)
                .build();
        return API.get("/mobile_location/aim_mobile", params, PhoneLocation.class);
    }
}
